package com.jzg.jcptadmin.ui;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.TextView;

import com.jzg.jcptadmin.R;
import com.jzg.jcptadmin.adpter.ExtendedViewPager1Adapter;
import com.jzg.jcptadmin.base.BaseActivity;
import com.jzg.jcptadmin.data.vo.CarDetails;
import com.jzg.jcptadmin.view.ExtendedViewPager;

import butterknife.Bind;
import butterknife.ButterKnife;

public class PhotoForNetActivity extends BaseActivity {

    @Bind(R.id.extendedVP)
    ExtendedViewPager extendedVP;
    int position;
    @Bind(R.id.title)
    TextView title;
    private LinearLayoutManager linearLayoutManager;
    public CarDetails details;
    private boolean isZonghe;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo);
        ButterKnife.bind(this);
        details = getIntent().getParcelableExtra("piclists");
        position = getIntent().getIntExtra("position", 0);
        isZonghe = getIntent().getBooleanExtra("isZonghe", false);
        extendedVP.setAdapter(new ExtendedViewPager1Adapter(appContext, details.getCarPicList(),isZonghe));
        extendedVP.setCurrentItem(position);
        linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        extendedVP.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                setShoePerNum(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        setShoePerNum(position);
    }

    private void setShoePerNum(int num) {
        num++;
        if (num <= 0)
            num = 1;
        title.setText(num + "/" + details.getCarPicList().size());
    }
}
